package com.polaris.live.adapter.recharge

import android.view.View
import com.blankj.utilcode.util.TimeUtils
import com.polaris.live.common.adapter.BaseBindingAdapter
import com.polaris.live.common.adapter.VBViewHolder
import com.polaris.live.databinding.AdapterRechargeActTimeBinding
import com.polaris.live.resp.back_resp.PayerRechargeDailyRewardsInfoVo

/**
 * RechargeActivityTimeAdapter
 *
 * @author Created by 半仙 on 2024/7/19/019 11:06
 */
class RechargeActTimeAdapter :
    BaseBindingAdapter<AdapterRechargeActTimeBinding, PayerRechargeDailyRewardsInfoVo>() {

    private var mSelectPosition = 0

    private var mTextSize = 19f
    override fun convert(
        holder: VBViewHolder<AdapterRechargeActTimeBinding>,
        item: PayerRechargeDailyRewardsInfoVo,
    ) {
        holder.vb.apply {
            if (mSelectPosition == holder.absoluteAdapterPosition) {
                ivSelectBack.visibility = View.VISIBLE
                tvTime.isSelected = true
                ivArrowIcon.visibility = View.VISIBLE
            } else {
                ivSelectBack.visibility = View.GONE
                tvTime.isSelected = false
                ivArrowIcon.visibility = View.GONE
            }
            tvTime.textSize = mTextSize
            tvTime.text = TimeUtils.millis2String(item.rewardsDate, "MM/dd")
        }
    }

    fun setSize(sizeF: Float) {
        mTextSize = sizeF
        notifyDataSetChanged()
    }

    fun setSelectPosition(position: Int) {
        mSelectPosition = position
        notifyDataSetChanged()
    }

    fun getSelectItem() = data[mSelectPosition]

}